C#, just like other languages, contains reserved words. These words are called keywords. Keywords have meaning to the compiler and cannot be used as variable, class, or any other object in the program.
Keywords in C# are categories as the following:
- Modifier keywords: Modifier keywords are keywords that can modify type and type members. They allow or prevent certain part of a program from being modified by other areas of that program.
- Access Modifier Keywords: Access modifiers keywords are used when declaring a class, property, field, and other variables.
- Statement Keywords: Statement keywords are used to create a follow for a program.
- Method parameter keywords: Method parameter keywords are used in a method signature.
- Namespace keywords: Namespace keywords are sued with namespaces implementation and related operations.
- Operator Keywords: Operator keywords are used to implement miscellaneous operations and actions.
- Access keywords: Access keywords are used to access a base class or class containers.
- Literal keywords: Literal keywords are used to instances or value of an object.
- Type keywords: Type keywords are used for data types in C#
- Contextual Keywords: Contextual keywords are the keywords that are considered as reserved words only if they are used in a certain way. They can be used in class name and other indentifies as they are not reserved words.
- Query keywords: Query keywords are used in SQL and LINQ queries.
The following table contains all keywords in C#. Keywords are sorted alphabetically and grouped by categories:
Keyword | Category | Description |
---|---|---|
abstract | Modifier keywords | Is used to implement classes, methods, properties, indexers, and events has an incomplete implementation. |
. operator | Namespace Keywords | Is used to overload a build-in operator in a class or struct implementation. |
:: operator | Namespace Keywords | Is used to search for C# built-in identifiers. |
add | Contextual Keywords | Is used to define an event that is invoked when a client code subscribes to you code. |
as | Operator Keywords | Is used to perform a type conversion between reference types, or nullable type. |
ascending | Query Keywords | |
async | Modifier keywords | |
await | Operator Keywords | |
base | Access keywords | |
bool | Type keywords | |
break | Statement Keywords | |
by | Query keywords | |
byte | Type keywords | |
case | Statement Keywords | |
catch | Statement Keywords | |
char | Type keywords | |
checked | Statement Keywords | |
checked | Operator Keywords | |
class | Type keywords | |
const | Modifier keywords | |
continue | Statement Keywords | |
decimal | Type keywords | |
default | Statement Keywords | |
descending | Query keywords | |
do | Statement Keywords | |
double | Type keywords | |
dynamic | Contextual Keywords | |
else | Statement Keywords | |
enum | Type keywords | |
equals | Query keywords | |
event | Modifier keywords | |
extern | Modifier keywords | |
extern alias | Namespace keywords | |
false | Literal keywords | |
finally | Statement Keywords | |
fixed | Statement Keywords | |
float | Type keywords | |
for | Statement Keywords | |
foreach | Statement Keywords | |
from | Query keywords | |
global | Contextual Keywords | |
goto | Statement Keywords | |
group | Query keywords | |
if | Statement Keywords | |
in | Statement Keywords | |
in | Query keywords | |
int | Type keywords | |
internal | Access Modifier Keywords | Allows other program code in the same assembly to access the type or its members. |
into | Query keywords | |
is | Operator Keywords | |
join | Query keywords | |
let | Query keywords | |
lock | Statement Keywords | |
long | Type keywords | |
new | Modifier keywords | |
new | Operator Keywords | |
null | Literal keywords | |
on | Query keywords | |
orderby | Query keywords | |
out | Method parameter keywords | |
override | Modifier keywords | |
partial | Modifier keywords | |
private | Access Modifier Keywords | Restricts other parts of a program from accessing the type and its members and allow code in the same class or struct to access it. |
protected | Access Modifier Keywords | Allows codes in the same class or a class that derives from that class to access the type or its members. |
public | Access Modifier Keywords | Allows any part of a program in a same assembly or another assembly to access the type and its members. |
readonly | Modifier keywords | |
ref | Method parameter keywords | |
return | Statement Keywords | |
sbyte | Type keywords | |
sealed | Modifier keywords | |
select | Query keywords | |
set | Contextual Keywords | |
short | Type keywords | |
sizeof | Operator Keywords | |
stackalloc | Operator Keywords | |
static | Modifier keywords | |
string | Type keywords | |
struct | Type keywords | |
switch | Statement Keywords | |
this | Access keywords | |
throw | Statement Keywords | |
true | Literal keywords | |
try | Statement Keywords | |
typeof | Operator Keywords | |
uint | Type keywords | |
ulong | Type keywords | |
unchecked | Statement Keywords | |
unchecked | Operator Keywords | |
unsafe | Modifier keywords | |
ushort | Type keywords | |
using | Namespace keywords | |
value | Literal keywords | |
value | Contextual Keywords | |
var | Contextual Keywords | |
virtual | Modifier keywords | |
void | Literal keywords | |
volatile | Modifier keywords | |
where | Query keywords | |
while | Statement Keywords | |
yield | Statement Keywords |
Comments